﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;

using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;

using System.Collections.Generic;
using HZ.DrugTrade.Web;
using HZ.DrugTrade.Model;
using HZ.DrugTrade.Model.Enum;
using HZ.DrugTrade.IBLL;
using HZ.DrugTrade.BLLFactory;

namespace HZ.DrugTrade.Web.Hospitals.StorageManage
{
    public partial class StorageGoodsDetails : BasePage
    {
        public StorageGoodsDetails()
        {
        }
        private int totalRecord;
        private IList<HZ.DrugTrade.Model.View.Distribution> PurchaseOrderDetailList;
        private IList<Model.View.PurchaseOrderDetail> aPurchaseOrderDetailList = new List<Model.View.PurchaseOrderDetail>();
        private IList<Distribution> aDistributionList = new List<Distribution>();
        private IBLL_Purchase iPurchase = Factory.BLL_Purchase();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                Binddata();
            }

        }


        protected void AspNetPager1_OnPageChanged(object sender, EventArgs e)
        {
            Binddata();
        }
        protected void btnQuery_Click(object sender, EventArgs e)
        {
            AspNetPager1.CurrentPageIndex = 1;
            Binddata();
        }

        protected void lbnSwitch_Click(object sender, EventArgs e)
        {
            if (lbnSwitch.CommandArgument == "simple")
            {
                ltlAdvance.Text = "";
                lbnSwitch.CommandArgument = "advance";
                lbnSwitch.Text = "简单查询";
            }
            else
            {
                ltlAdvance.Text = "<tbody id='advance' style='display:none'>";
                lbnSwitch.CommandArgument = "simple";
                lbnSwitch.Text = "高级查询";

                //清空数据
                txtAddTimeFrom.Text = "";
                txtAddTimeTo.Text = "";
                txtCompanyName_PS.Text = "";
                txtCompanyName_SC.Text = "";
                txtGoodsName.Text = "";
            }
        }

        protected void Binddata()
        {
            Model.Query.Distribution qryCondition = new HZ.DrugTrade.Model.Query.Distribution();
            qryCondition.OrderDetailID = new HZ.Common.ConvertHelper(Request.QueryString["OID"]).String;
            qryCondition.CompanyName_SC = txtCompanyName_SC.Text.Trim();
            qryCondition.CompanyName_PS = txtCompanyName_PS.Text.Trim();
            qryCondition.GoodsName = txtGoodsName.Text.Trim();
            qryCondition.Outlookc = txtOutLook.Text.Trim();
            qryCondition.Material = txtMaterial.Text.Trim();
            qryCondition.DistributeTimeFrom =new HZ.Common.ConvertHelper(txtAddTimeFrom.Text.Trim()).ToDateTime;
            qryCondition.DistributeTimeTo =new HZ.Common.ConvertHelper(txtAddTimeTo.Text.Trim()).ToDateTime;
            qryCondition.SortFields = " DistributeTime desc,OrderName ASC ";
            PurchaseOrderDetailList = iPurchase.GetPurchaseOrderDetail_AcceptByWhere(qryCondition, this.AspNetPager1.CurrentPageIndex, AspNetPager1.PageSize, out totalRecord);

            this.gvwProduceCatalog.AutoGenerateColumns = false;
            gvwProduceCatalog.DataSource = PurchaseOrderDetailList;
            gvwProduceCatalog.DataBind();
            this.AspNetPager1.RecordCount = totalRecord;


        }

        protected void gvwProduceCatalog_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {

            }


        }
    }
}


